<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:c="http://java.sun.com/jstl/core"
    template="layout/template.xhtml">

    <ui:define name="l_content">
		<ui:include src="/l_content/lc.xhtml" />
    </ui:define>
    
    <ui:define name="body">
    	<a:form>
	    	<a:poll id="poll" interval="60000" enabled="true"
	                reRender="comm_panel" action="#{kWall.loadComments()}" />
    	</a:form>
    	<h:panelGroup id="comment_panel">
			<h:form id="comments_form">
				<h:panelGroup id="comm_panel" styleClass="no_border">
					<h:outputText value="#{messages.comments_msg}: " styleClass="b"/>&#160;
					<h:outputText value="#{kWall.commentList.size}" styleClass="red b"/>
					<rich:dataTable id="comments_" value="#{kWall.commentList}" var="e" rows="50" 
						rendered="#{kWall.commentList.size gt 0}" style="width:450px !important;">
						<rich:column width="250" >
							<table width="100%" >
								<tr>
									<td width="52" valign="top" style="padding-top: 4px;">
										<s:fragment rendered="#{e.userAvb}" >
											<a href="#{facesContext.externalContext.requestContextPath}/k_profile.k?userId=#{e.userId}" >
												<s:fragment rendered="#{e.thumbAvb}">
													<img src="/#{kInitParam.imgPath}/av_#{e.userId}/#{e.thumb}" width="50" height="50"/>
												</s:fragment>
												<s:fragment rendered="#{!e.thumbAvb}">
													<img src="img/no-img.gif" width="50" height="50" />												
												</s:fragment>
											</a>
										</s:fragment>
									</td>
									<td valign="top" style="padding-left: 10px;padding-top: 4px;">
										<s:fragment rendered="#{e.userAvb}" >
											<a href="#{facesContext.externalContext.requestContextPath}/k_profile.k?userId=#{e.userId}" >
												<h:outputText value="#{e.name}" styleClass="b"/>&#160;
											</a>
										</s:fragment>
										<s:fragment rendered="#{!e.userAvb}" >
											<h:outputText value="#{e.name}" styleClass="b"/>&#160;
										</s:fragment>
										<h:outputText value="#{e.comment}" />
										<div style="height: 4px;clear: both;"></div>
										<h:outputText value="#{e.created}" styleClass="gray">
											<s:convertDateTime pattern="dd MMM yyyy HH:mm"/>
										</h:outputText>
									</td>
								</tr>
							</table>
						</rich:column>
					</rich:dataTable>
					<rich:datascroller for="comments_" renderIfSinglePage="false" />
				</h:panelGroup>
			</h:form>
			<hr width="500px" align="left"/>
			<h:form id="add_form">
				<table>
					<tr>
						<td class="b">
							<h:outputLabel value="#{messages.name_msg}" for="name_" /><span class="m">*</span>
						</td>
						<td>
							<h:inputText id="name_" value="#{kWall.name}" rendered="#{!identity.loggedIn}" required="true"/>
							<h:outputText id="user_name_" value="#{kUser.user.fullName}" rendered="#{identity.loggedIn}" />
						</td>
					</tr>
					<tr>
						<td class="b">
							<h:outputLabel value="#{messages.comment_msg}" for="comment_" /><span class="m">*</span>
						</td>
						<td>
							<h:inputTextarea id="comment_" value="#{kWall.comment}" required="true" cols="50" rows="6"/>
						</td>
					</tr>
					<tr>
						<td>
						</td>
						<td>
							<a:commandButton action="#{kWall.addComment()}" value="#{messages.send_msg}" reRender="comment_panel, comments_, messages" />
						</td>
					</tr>
				</table>
			</h:form>
		</h:panelGroup>
    </ui:define>
</ui:composition>
